using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Calc.Execution;

namespace Calc.UI.WinForms
{
	public partial class Main : Form
	{
		protected ExecutionEngine _engine;

		public Main()
		{
			InitializeComponent();

			_engine = new ExecutionEngine();
		}

		private void txtStatement_KeyDown(object sender, KeyEventArgs e)
		{
			switch ( e.KeyCode )
			{
				case Keys.Enter:
					// run statement
					ExecutionResult result = _engine.ExecuteLine(txtStatement.Text);

					txtStatement.Text = "";
					if ( result.Result != ExecutionType.Error )
					{
						lstHistory.Items.Add(txtStatement.Text);
						lstHistory.Items.Add(result.Message);
					}
					else
					{
						//lstHistory.Items.Add(txtStatement.Text);
						//lstHistory.Items.Add(result.Message);
					}
					break;
				case Keys.Up:
					// cycle through history backwards
					break;
			}

		}
	}
}